Skip to content

feat(core): replace 80% size threshold with count-first chain-to-full fallback#531

Merged
JusterZhu merged 2 commits into
masterfrom
feat/chain-count-threshold
Jun 21, 2026
Merged

feat(core): replace 80% size threshold with count-first chain-to-full fallback#531
JusterZhu merged 2 commits into
masterfrom
feat/chain-count-threshold

Conversation

@JusterZhu

Copy link
Copy Markdown
Collaborator

Closes #530

Summary

Replaces the single 80%-of-full-size threshold in DownloadPlanBuilder with a count-first heuristic for choosing between chain packages and a full replacement package.

Before

// 80% of full size threshold
var threshold = (long)(bestFull.Size * 0.8);
if (chainTotal >= threshold)full package

After

// Count-first: too many chain packages → full
if (maxChainBeforeFallback > 0 && chainCount > maxChainBeforeFallback)full package

// Size guardrail: chain is larger than full → full
if (chainTotal >= bestFull.Size)full package

Why

  • Package count matters. 20 small chain packages have 20 points of failure (download, hash verify, patch apply). Fewer packages = more reliable updates.
  • Runtime fallback already exists. Chain packages are paired with FallbackFull — a failed patch falls back automatically. We don't need an eager 80% threshold at download time.
  • No absolute overpay. Old logic could make users download 400 MB extra (20% of 2 GB). New logic only switches when it genuinely saves data or reliability demands it.
  • Configurable. MaxChainBeforeFallback defaults to 8 in UpdateConfiguration, set to 0 to disable count-based fallback.

Changes

File Change
UpdateConfiguration.cs + MaxChainBeforeFallback property (default 8)
DownloadPlanBuilder.cs New count+size heuristic, new parameter
ClientStrategy.cs Pass MaxChainBeforeFallback to Build
DownloadPlanBuilderTests.cs 5 new test cases

🤖 Generated with Claude Code

… fallback

Swap the single 80%-of-full-size heuristic for a two-condition strategy:
1. Chain count exceeds MaxChainBeforeFallback (default 8) → full package
2. Combined chain size >= full size → full package

Add MaxChainBeforeFallback to UpdateConfiguration (default 8), plumb it
through DownloadPlanBuilder.Build() and ClientStrategy. The new logic
stops switching to full when the chain total is only marginally below
the full size — the runtime fallback (FallbackFull) already handles
chain application failures, so an overly eager size threshold is
unnecessary.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 21, 2026 07:06

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

…d-AppType tests

Code review fixes:
- Extract duplicated 'switch to full' code block into local function SwitchToFull
- Add missing MaxChainBeforeFallback mapping in ConfigurationMapper
- Add 3 mixed-AppType test cases (Client+Upgrade split scenarios)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@JusterZhu JusterZhu force-pushed the feat/chain-count-threshold branch from 11c4919 to 0a8c4a2 Compare June 21, 2026 07:09
@JusterZhu JusterZhu merged commit c6b8233 into master Jun 21, 2026
3 checks passed
@JusterZhu JusterZhu deleted the feat/chain-count-threshold branch June 21, 2026 07:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Replace 80% size threshold with count-first chain-to-full fallback heuristic

2 participants